package com.zyr.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zyr.domain.Order;
import com.zyr.service.OrderService;
import com.zyr.mapper.OrderMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 35747
* @description 针对表【order】的数据库操作Service实现
* @createDate 2024-07-28 20:03:33
*/
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order>
    implements OrderService{
    @Resource
    private OrderMapper orderMapper;

    @Override
    public List<Order> getListByUserId(long userId) {
       List<Order> orders =  orderMapper.selectOrderByUserId(userId);
        return orders;
    }

    @Override
    public boolean saveit(Order order) {
        String orderName = order.getOrderName();
        String orderDescription = order.getOrderDescrition();
        // 模拟远程失败异常
        int insert = orderMapper.save(orderName, orderDescription);
        return insert > 0;
    }
}




